/***************************************************************************
 *   Copyright (C) 2007 by Ziman & Xloverin                                *
 *   ziman@centrum.sk, xloverin@gmail.com                                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef NICKLIST_H
#define NICKLIST_H

#include <QMap>
#include <QString>
#include <QSqlQuery>
#include <QHttp>
#include <QObject>
#include <QList>

/**
 * Uchovava zoznam nickov na talkri a umoznuje ho manazovat.
 * @author Ziman & Xloverin <ziman@centrum.sk, xloverin@gmail.com>
 */
class NickList : public QObject {
	
	Q_OBJECT
public:
	
	struct Nick {
		QString nick, g, d, a, l, i;
	};
	
    NickList();
    ~NickList();
	
	void loadFromUrl(const QString &url);
	QList<QString> list() const;
	const Nick *operator[](const QString &nick) const;
	
private:
	
	/// ID posledneho get-u.
	int getId;
	QHttp http;
	QMap<QString, Nick> nickList;
	
	void loadFromDb();
	void saveToDb();
	
private slots:
			
	void on_http_requestFinished(int id, bool error);
};

#endif
